<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/vectrics.tld" prefix="vectrics" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%@ page import="org.vectrics.user.UserAuthService" %>
<%@ page import="org.vectrics.provider.*" %>
<%@ page import="org.vectrics.user.*" %>
<%@ page import="java.util.*" %>
<%@ page import="org.vectrics.hibernate.ThreadProperties" %>
<%@ page import="org.vectrics.domain.Domain" %>
<%@ page import="org.vectrics.common.util.*" %>
<%@ page import="org.vectrics.struts.*" %>


<%
	Request vectricsRequest = HttpRequestConverter.convertRequest(request);
	String domainId = ThreadProperties.getUriDomainId();
	Domain domain = ThreadProperties.getDomain();
	String uploadResumeHref = "/recruit/profile/" + domainId + "/resume/upload.do";
	Person person = CoreServiceLocator.getUserAuthService().getAuthorizedPerson(vectricsRequest);

	if (person == null) {
		person = CoreServiceLocator.getPersonService().findPersonWithUserName(domain, request.getParameter("userName"));
	}
	
	User user = person.getUser();
	String userId = null;
	if (user != null) {
		userId = person.getId().toString();		
	}
	else {
%>
		<h1>No Authorized User Logged In</h1>
<%
	}

	String resumeName = 
		CoreServiceLocator.getPhraseProvider().getMessage("phrase.resume.name.default", request.getLocale());
	resumeName += " " + CoreServiceLocator.getDateFormat().getDateFormatRoundToDay(request.getLocale()).format(DateSync.getCurrentTime());

	String section = request.getParameter("section");
	String code = request.getParameter("code");
	String type = request.getParameter("type");
	String host = request.getContextPath();
	Date now = new Date();
	long uid = now.getTime();
	uid += code.hashCode();
	String src = host + "/cmsimage/" + code + "." + type
		+ "?domain=" + domain.getId() + "&instance=" + uid
		+ "&section=" + section 
		+ "&code=" + code
		+ "&type=" + type;

%>
<vectrics:errors debug="false"/>

<img src="<%=src%>"/> 
<form action="/hrs-intranet/admin/content/saveimage.do" method="POST" enctype="multipart/form-data">

	<input type="hidden" name="code" value="<%=code%>">
	<input type="hidden" name="section" value="<%=section%>">
	<table>
		<tr>
			<td>
				<input type="file" name="theFile" class="formEditClass">
			</td>
		</tr>
	</table>
	
	<vectrics:formButton 
			name="submit" 
			code="public.button.wide" 
			phraseCode="button.image.upload"/>
</form>





